package com.weiiew.itemservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weiiew.common.entity.cal.calItem;
import com.weiiew.common.entity.factory.FactoryRecipe;
import com.weiiew.common.entity.simple.Countable;
import com.weiiew.common.entity.simple.Pair;
import com.weiiew.common.entity.simple.SimpleBuilding;
import com.weiiew.common.entity.simple.SimpleItem;
import com.weiiew.common.entity.vo.RecipeItemVO;
import com.weiiew.common.entity.dto.Item;
import com.weiiew.common.entity.qo.ItemQo;
import com.weiiew.common.entity.vo.ItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 魏锴
 * @description 针对表【item】的数据库操作Mapper
 * @createDate 2024-02-05 00:34:27
 * @Entity com.example.adminBackEnd.Entity.dao.Item
 */
@Mapper
public interface ItemMapper extends BaseMapper<Item> {


    List<Countable> selectCostsByBuilding(Integer build_id);


    @Update("update item set default_recipe = #{recipe_id} where id = #{item_id}")
    void setDefaultRecipe(Integer item_id, Long recipe_id);

    List<Integer> getItemStackSizes(int version);

    List<ItemVO> getItemList(ItemQo qo);
    Integer getItemLength(ItemQo qo);

    List<SimpleItem> getSimpleItemList(ItemQo qo);

    ItemVO getItemById(Integer id);


    @Update("update item set icon_url = #{id} where id = #{id}")
    int setIcon(int id);

    @Select("select icon_url from item where id = #{id}")
    String getIconById(Integer id);

    @Select("select id from item where name = #{name} and version = #{version}")
    Integer getItemByName(String name, Integer version);




    List<RecipeItemVO> getIngredientsById(Integer recipe_id);

    List<RecipeItemVO> getProductsById(Integer recipe_id);

    List<SimpleBuilding> getBuildingsById(Integer recipe_id);

    @Select("select icon_url from item where version = #{version}")
    List<String> getItemIconList(Integer version);

    List<SimpleItem> getItemListOrderByUse(Integer version);

    List<calItem> getCalRecipeItemList(@Param("version") Integer version, @Param("name") String name);

    List<Pair> getIdNameList(int version);

    List<FactoryRecipe> getRecipeList(int version);
}




